package user.service.impl;

import core.enums.ResultCode;
import core.exception.ServiceException;
import file.domain.OSSResult;
import file.service.OSSService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import user.service.IFileService;
@Service
@Slf4j
public class FileServiceImpl implements IFileService {

    @Autowired
    private OSSService ossService;
    @Override
    public OSSResult uploadFile(MultipartFile file) {
        OSSResult ossResult;
        try {
            ossResult = ossService.uploadFile(file);
        } catch (Exception e) {
            log.error("上传文件失败 {}", e.getMessage());
            throw new ServiceException(ResultCode.FAILED_FILE_UPLOAD);
        }
        return ossResult;
    }
}
